Skip to content

Preserve Gauss-von-Mises single-point autograd - #5255

Open
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/preserve-gauss-von-mises-single-point-autograd
Open

Preserve Gauss-von-Mises single-point autograd#5255
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/preserve-gauss-von-mises-single-point-autograd

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Bug

GaussVonMisesDistribution.pdf(...) kept backend-native values for batched evaluation, but the single-point path returned float(p[0]).

On the PyTorch backend, a query tensor with requires_grad=True therefore produced a Python float. The conversion silently detached the density from the computation graph, so callers could not differentiate a single-point likelihood even though the equivalent batched path remained differentiable.

Fix

Return the backend scalar p[0] directly for single-point evaluation instead of converting it to Python float.

This preserves the existing numerical value while keeping the active backend's dtype, device, and autograd history.

Regression coverage

Add a PyTorch-backend regression that evaluates a single Gauss-von-Mises point with requires_grad=True and verifies:

  • the result is a scalar PyTorch tensor;
  • dtype and device match the query;
  • the density is finite and positive;
  • backpropagation reaches both query coordinates with finite, nonzero gradients.

Validation

  • independently confirmed that converting a differentiable PyTorch scalar with float(...) returns a plain Python float and loses autograd;
  • final production diff is one line;
  • branch is based directly on current main (f196ec41d1d8681e279936db9f1a0a3abfa276e7) and is 2 commits ahead / 0 behind;
  • GitHub Actions is authoritative for the full backend, lint, packaging, documentation, and integration matrix.

@FlorianPfaff
FlorianPfaff marked this pull request as ready for review August 6, 2026 19:42
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 7, 2026 02:19
auto-merge was automatically disabled August 10, 2026 14:46

Pull request was closed

@FlorianPfaff FlorianPfaff reopened this Aug 10, 2026
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 10, 2026 14:46
@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 30.06s
✅ JSON prettier 7 0 0 0 1.19s
✅ JSON v8r 7 0 0 4.28s
✅ MARKDOWN markdownlint 68 0 0 0 1.85s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.66s
✅ PYTHON black 1867 87 0 0 98.36s
✅ PYTHON isort 1867 141 0 0 2.86s
✅ REPOSITORY betterleaks yes no no 3.08s
✅ REPOSITORY checkov yes no no 50.4s
✅ REPOSITORY gitleaks yes no no 17.9s
✅ REPOSITORY git_diff yes no no 0.37s
✅ REPOSITORY secretlint yes no no 83.24s
✅ REPOSITORY syft yes no no 6.19s
✅ REPOSITORY trivy-sbom yes no no 7.15s
✅ REPOSITORY trufflehog yes no no 33.32s
✅ YAML prettier 11 0 0 0 0.77s
✅ YAML v8r 11 0 0 13.65s
✅ YAML yamllint 11 0 0 0.57s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.6.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant